package com.fsc.fragment;

import com.fsc.fragment.login.Password;
import com.fsc.fragment.login.PasswordDao;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class AddPasswordActivity extends Activity implements OnClickListener{
	private EditText et_login;
	private Button btn_save;
	
	private PasswordDao Dao;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);	
		setContentView(R.layout.activity_add_password);
		
		et_login = (EditText) findViewById(R.id.et_login);
		btn_save = (Button) findViewById(R.id.btn_save);
		
		btn_save.setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		String name = et_login.getText().toString();
		if(name == null || name.length()<=0){
			Toast.makeText(AddPasswordActivity.this, "请输入新密码", Toast.LENGTH_SHORT).show();
			return;
		}
		else{
			Dao = new PasswordDao(AddPasswordActivity.this);
			Dao.insert(new Password(name));
			Toast.makeText(AddPasswordActivity.this, "重置密码成功！", Toast.LENGTH_SHORT).show();
			finish();
		}
	
	}
}
